package com.issac.controller;

import com.issac.common.R;
import com.issac.entity.Retailer;
import com.issac.service.RetailerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName RetailerController
 * @Author zy
 * @Date 2021/10/29 11:47
 * @Description RetailerController
 * @Version 1.0
 */
@RestController
public class RetailerController {
    @Autowired
    RetailerService retailerService;

    // 添加零售商
    @PostMapping("/addRetailer")
    public R addRetailer(@RequestBody Retailer retailer){
        return retailerService.addRetailer(retailer);
    }

    // 查询全部零售商
    @PreAuthorize("hasAuthority('admin')")
    @PostMapping("/selectAllRetailer")
    public R selectAllRetailer(){
        return retailerService.selectAllRetailer();
    }

    // 修改零售商信息
    @PostMapping("/updateRetailer")
    public R updateRetailer(@RequestBody Retailer retailer){
        return retailerService.updateRetailer(retailer);
    }

    // 软删除零售商记录(mybatis-plus实现)
    @GetMapping("/deleteRetailerById")
    public R deleteRetailerById(@RequestParam("id") String id){
        return retailerService.deleteRetailerById(id);
    }
}


















